package com.koron.order.overhaul.bean.dto;

import com.koron.order.common.bean.base.ButtonCode;
import com.koron.order.common.bean.base.ButtonUserType;
import com.koron.order.common.bean.base.JurisdictionUserType;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum OverhaulStatus implements Comparator<OverhaulStatus> {

    DRAFT("DRAFT", "草稿", 1),
    WAIT_DISPATCH("WAIT_DISPATCH", "待派工", 2),
    WAIT_EXECUTE("WAIT_EXECUTE", "待执行", 3),
    IN_EXECUTE("IN_EXECUTE", "执行中", 4),
    PREPARE_REPORT("PREPARE_REPORT", "编制大修报告", 5),
    WAIT_ACCEPT("WAIT_ACCEPT", "待验收", 6),
    ARCHIVED("ARCHIVED", "已归档", 7),
    PENGDING("PENGDING", "待处理", 8),
    DEPRECATED("DEPRECATED", "已废弃", 10);

    private String status;
    private String desc;
    private int sort;

    OverhaulStatus(String var1, String var2, int sort) {
        this.status = var1;
        this.desc = var2;
        this.sort = sort;
    }

    public String getStatus() {
        return status;
    }

    public String getDesc() {
        return desc;
    }

    public int getSort() {
        return sort;
    }

    public static OverhaulStatus getOverhaulStatus(String status) {

        switch (status) {
            case "DRAFT":
                return DRAFT;
            case "WAIT_DISPATCH":
                return WAIT_DISPATCH;
            case "WAIT_EXECUTE":
                return WAIT_EXECUTE;
            case "IN_EXECUTE":
                return IN_EXECUTE;
            case "PREPARE_REPORT":
                return PREPARE_REPORT;
            case "WAIT_ACCEPT":
                return WAIT_ACCEPT;
            case "ARCHIVED":
                return ARCHIVED;
            case "PENGDING":
                return PENGDING;
            case "DEPRECATED":
                return DEPRECATED;
        }
        return null;
    }


    @Override
    public int compare(OverhaulStatus o1, OverhaulStatus o2) {
        return o1.getSort() - o2.getSort();
    }

    //获取与前端统一过的页面按钮编码
    public static Map<String, List<String>> getPageButtonCode(String status) {

        switch (status) {
            case "DRAFT":
                Map<String, List<String>> draft_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(draft_cond, ButtonCode.save, JurisdictionUserType.creater,JurisdictionUserType.createOrg);
                ButtonUserType.put(draft_cond, ButtonCode.submit, JurisdictionUserType.creater,JurisdictionUserType.createOrg);
                ButtonUserType.put(draft_cond, ButtonCode.delete, JurisdictionUserType.creater,JurisdictionUserType.createOrg);

                return draft_cond;
            case "WAIT_DISPATCH":
                Map<String, List<String>> wait_dispatch_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(wait_dispatch_cond, ButtonCode.save, JurisdictionUserType.createOrg, JurisdictionUserType.workFlowAudit);
                ButtonUserType.put(wait_dispatch_cond, ButtonCode.dispatch, JurisdictionUserType.createOrg, JurisdictionUserType.workFlowAudit);
                ButtonUserType.put(wait_dispatch_cond, ButtonCode.changeDispatch, JurisdictionUserType.workFlowAudit);
                return wait_dispatch_cond;
            case "WAIT_EXECUTE":
                Map<String, List<String>> wait_execute_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(wait_execute_cond, ButtonCode.execute, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(wait_execute_cond, ButtonCode.application, JurisdictionUserType.deptManageOrg);
                ButtonUserType.put(wait_execute_cond, ButtonCode.handleTicketWork, JurisdictionUserType.createOrg, JurisdictionUserType.deptManageOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(wait_execute_cond, ButtonCode.orderChange, JurisdictionUserType.createOrg, JurisdictionUserType.workFlowAudit);

                return wait_execute_cond;
            case "IN_EXECUTE":
                Map<String, List<String>> in_execute_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(in_execute_cond, ButtonCode.save, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.deleteExecute, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.addExecute, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.submit, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.application, JurisdictionUserType.deptManageOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.handleTicketWork, JurisdictionUserType.createOrg, JurisdictionUserType.deptManageOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.linkExperiment, JurisdictionUserType.createOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.concession, JurisdictionUserType.createOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                ButtonUserType.put(in_execute_cond, ButtonCode.question, JurisdictionUserType.createOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg);
                return in_execute_cond;

            case "PREPARE_REPORT":
                Map<String, List<String>> prepare_report_cond = new HashMap<String, List<String>>();
                ButtonUserType.put(prepare_report_cond, ButtonCode.save, JurisdictionUserType.createOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg,JurisdictionUserType.workOrg);
                ButtonUserType.put(prepare_report_cond, ButtonCode.submit, JurisdictionUserType.createOrg, JurisdictionUserType.deptWorkUser, JurisdictionUserType.worker, JurisdictionUserType.leader, JurisdictionUserType.leaderOrWorkerOrg,JurisdictionUserType.workOrg);

                return prepare_report_cond;
            case "WAIT_ACCEPT":
                Map<String, List<String>> wait_accept_cond = new HashMap<String, List<String>>();
                return wait_accept_cond;

            case "ARCHIVED":
                Map<String, List<String>> archived_cond = new HashMap<String, List<String>>();

                return archived_cond;
            default:
                return new HashMap<>();
        }

    }

}
